package bird.linkedlist;

/**
 * @author sijunqiang
 * @data 2021/5/23 18:21
 * @description: 测试链表
 */
public class Main {
    public static void main(String[] args) {

        LinkedList<Integer> linkedList = new LinkedList<>();
        //Test add element to linkedList
        for (int i = 0; i <5; i++) {
         linkedList.addFirst(i);
            System.out.println(linkedList);
        }

        // Test add every element to linkedList
         linkedList.add(3,666);
        System.out.println( linkedList);

         //Test get element
        Integer integer = linkedList.get(3);
        System.out.println(integer);
        System.out.println( linkedList);

        // Test set element
        Integer set = linkedList.set(3, 777);
        System.out.println("origin = " + set);
        System.out.println(linkedList);

         // Test remove element
        Integer remove = linkedList.remove(3);
        System.out.println("remove = " + remove);
        System.out.println(linkedList);

        Integer first  = linkedList.removeFirst();
        System.out.println("first = " + first);
        System.out.println(linkedList);

          // Test remove last
        Integer last = linkedList.removeLast();
        System.out.println(last);
        System.out.println(linkedList);
    }
}
